package com.ruoyi.manage.article.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.manage.article.domain.AuthInfo;
import com.ruoyi.manage.article.mapper.AuthInfoMapper;
import com.ruoyi.manage.article.service.IAuthInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户认证管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/article/score")
public class AuthScoreInfoController extends BaseController
{
    @Autowired
    private IAuthInfoService authInfoService;

    @Autowired
    private AuthInfoMapper authInfoMapper;



    /**
     * 查询用户认证管理列表
     */
    @PreAuthorize("@ss.hasPermi('article:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuthInfo authInfo)
    {
        startPage();
        List<AuthInfo> list = authInfoService.selectAuthScoreInfoList(authInfo);
        return getDataTable(list);
    }

    /**
     * 导出用户认证管理列表
     */
    @PreAuthorize("@ss.hasPermi('article:info:export')")
    @Log(title = "用户认证管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuthInfo authInfo)
    {
        List<AuthInfo> list = authInfoService.selectAuthScoreInfoList(authInfo);
        ExcelUtil<AuthInfo> util = new ExcelUtil<AuthInfo>(AuthInfo.class);
        util.exportExcel(response, list, "用户认证管理数据");
    }


    /**
     * 新增 或者更改评分信息
     */
    @PreAuthorize("@ss.hasPermi('article:info:add')")
    @Log(title = "用户认证管理", businessType = BusinessType.INSERT)
    @PutMapping
    public AjaxResult saveOrUpdate(@RequestBody AuthInfo authInfo)
    {
        return toAjax(authInfoService.saveOrUpdateScoreAuthInfo(authInfo));
    }






}
